/*
 * acooly.cn Inc.
 * Copyright (c) 2017 All Rights Reserved.
 * create by ouwen
 * date:2017-09-27
 */
package com.yiji.fintech.musfinance.service.impl;

import com.acooly.core.common.dao.support.PageInfo;
import com.acooly.core.common.service.EntityServiceImpl;
import com.acooly.core.utils.Collections3;
import com.yiji.fintech.musfinance.common.exception.DBException;
import com.yiji.fintech.musfinance.dao.SignInfoDao;
import com.yiji.fintech.musfinance.entity.SignInfo;
import com.yiji.fintech.musfinance.service.SignInfoService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * center_sign_info Service实现
 *
 * Date: 2017-09-27 15:28:51
 *
 * @author ouwen
 *
 */
@Service("signInfoService")
public class SignInfoServiceImpl extends EntityServiceImpl<SignInfo, SignInfoDao> implements SignInfoService {

    @Override
    public List<SignInfo> query(SignInfo signInfo, Map<String, Boolean> sortMap, int pageNum, int pageSize) {
            Map<String,Object> map = new HashMap<>();
            map.put("EQ_accountNo", signInfo.getAccountNo());
            map.put("EQ_accountName",signInfo.getAccountName());
            map.put("EQ_certNo",signInfo.getCertNo());
            map.put("EQ_phoneNo",signInfo.getPhoneNo());
            map.put("EQ_elementType",signInfo.getElementType());
            PageInfo<SignInfo> pageInfo = new PageInfo<>();
            pageInfo.setCurrentPage(pageNum);
            pageInfo.setCountOfCurrentPage(pageSize);
            try {
                pageInfo = getEntityDao().query(pageInfo, map, sortMap);
            } catch (Exception e) {
                throw new DBException(e.getMessage());
            }
            return pageInfo.getPageResults();
    }

    @Override
    public SignInfo query(SignInfo signInfo) {
        List<SignInfo> signInfos = query(signInfo,null,1,1);
        if(Collections3.isNotEmpty(signInfos)){
            return signInfos.get(0);
        }
        return null;
    }

}
